
import derelict.sdl.sdl;
import std.stdio:writefln;

class FPS{

	this(uint _fpsRefresh){
		fpsRefresh = _fpsRefresh;
		startTicks = SDL_GetTicks();
	}

	void nextFrame(){
		frames++;
	}

	void update(){
		uint ticks = SDL_GetTicks();
		if(ticks - startTicks > fpsRefresh){
			writefln("FPS:",1000.f * cast(float)frames/(ticks - startTicks));
			startTicks = ticks;
			frames = 0;
		}
	}

	long frames;
	uint startTicks;
	uint fpsRefresh;
}
